﻿/**
<code>
  <author name="Zealic" email="zealic(at)gmail.com" type="Creator"/>
</code>
**/
using System;
using System.Text;


namespace Zealib.Win32
{
    public class Win32Console
    {
        public string GetPassword()
        {
            ConsoleKeyInfo info;
            StringBuilder sb = new StringBuilder(32);
            do
            {
                info = Console.ReadKey(true);
                if (char.IsLetterOrDigit(info.KeyChar) 
                    || char.IsSymbol(info.KeyChar)
                    || char.IsPunctuation(info.KeyChar)
                    || char.IsSeparator(info.KeyChar))
                {
                    sb.Append(info.KeyChar);
                    Console.Write('*');
                    continue;
                }
            } while (info.Key != ConsoleKey.Enter);
            Console.WriteLine();
            return sb.ToString();
        }
    }
}
